home *** CD-ROM | disk | FTP | other *** search
/ Risc World 5 / Risc World 5.iso / SOFTWARE / Issue3 / Games / xrick / !xrick / src / c / e_bomb < prev    next >
Text File  |  2004-06-24  |  3KB  |  154 lines

  1. /*
  2.  * xrick/src/e_bomb.c
  3.  *
  4.  * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
  5.  *
  6.  * The use and distribution terms for this software are contained in the file
  7.  * named README, which can be found in the root of this distribution. By
  8.  * using this software in any fashion, you are agreeing to be bound by the
  9.  * terms of this license.
  10.  *
  11.  * You must not remove this notice, or any other, from this software.
  12.  */
  13.  
  14. #include "system.h"
  15. #include "game.h"
  16. #include "ents.h"
  17. #include "e_bomb.h"
  18.  
  19. #include "e_rick.h"
  20.  
  21. /*
  22.  * public vars (for performance reasons)
  23.  */
  24. U8 e_bomb_lethal;
  25. U8 e_bomb_xc;
  26. U16 e_bomb_yc;
  27.  
  28. /*
  29.  * private vars
  30.  */
  31. U8 e_bomb_ticker;
  32.  
  33. /*
  34.  * Bomb hit test
  35.  *
  36.  * ASM 11CD
  37.  * returns: TRUE/hit, FALSE/not
  38.  */
  39. U8 e_bomb_hit(U8 e)
  40. {
  41.     if (ent_ents[e].x > (E_BOMB_ENT.x >= 0xE0 ? 0xFF : E_BOMB_ENT.x + 0x20))
  42.             return FALSE;
  43.     if (ent_ents[e].x + ent_ents[e].w < (E_BOMB_ENT.x > 0x04 ? E_BOMB_ENT.x - 0x04 : 0))
  44.             return FALSE;
  45.     if (ent_ents[e].y > (E_BOMB_ENT.y + 0x1D))
  46.             return FALSE;
  47.     if (ent_ents[e].y + ent_ents[e].h < (E_BOMB_ENT.y > 0x0004 ? E_BOMB_ENT.y - 0x0004 : 0))
  48.             return FALSE;
  49.     return TRUE;
  50. }
  51.  
  52. /*
  53.  * Initialize bomb
  54.  */
  55. void e_bomb_init(U16 x, U16 y)
  56. {
  57.     E_BOMB_ENT.n = 0x03;
  58.     E_BOMB_ENT.x = x;
  59.     E_BOMB_ENT.y = y;
  60.     e_bomb_ticker = E_BOMB_TICKER;
  61.     e_bomb_lethal = FALSE;
  62.  
  63.     /*
  64.      * Atari ST dynamite sprites are not centered the
  65.      * way IBM PC sprites were ... need to adjust things a little bit
  66.      */
  67. #ifdef GFXST
  68.     E_BOMB_ENT.x += 4;
  69.     E_BOMB_ENT.y += 5;
  70. #endif
  71.  
  72. }
  73.  
  74.  
  75. /*
  76.  * Entity action
  77.  *
  78.  * ASM 18CA
  79.  */
  80. void
  81. e_bomb_action(UNUSED(U8 e))
  82. {
  83.     /* tick */
  84.     e_bomb_ticker--;
  85.  
  86.     if (e_bomb_ticker == 0)
  87.     {
  88.         /*
  89.          * end: deactivate
  90.          */
  91.         E_BOMB_ENT.n = 0;
  92.         e_bomb_lethal = FALSE;
  93.     }
  94.     else if (e_bomb_ticker >= 0x0A)
  95.     {
  96.         /*
  97.          * ticking
  98.          */
  99. #ifdef ENABLE_SOUND
  100.         if ((e_bomb_ticker & 0x03) == 0x02)
  101.             syssnd_play(WAV_BOMBSHHT, 1);
  102. #endif
  103. #ifdef GFXST
  104.         /* ST bomb sprites sequence is longer */
  105.         if (e_bomb_ticker < 40)
  106.             E_BOMB_ENT.sprite = 0x99 + 19 - (e_bomb_ticker >> 1);
  107.         else
  108. #endif
  109.         E_BOMB_ENT.sprite = (e_bomb_ticker & 0x01) ? 0x23 : 0x22;
  110.     }
  111.     else if (e_bomb_ticker == 0x09)
  112.     {
  113.         /*
  114.          * explode
  115.          */
  116. #ifdef ENABLE_SOUND
  117.         syssnd_play(WAV_EXPLODE, 1);
  118. #endif
  119. #ifdef GFXPC
  120.         E_BOMB_ENT.sprite = 0x24 + 4 - (e_bomb_ticker >> 1);
  121. #endif
  122. #ifdef GFXST
  123.         /* See above: fixing alignment */
  124.         E_BOMB_ENT.x -= 4;
  125.         E_BOMB_ENT.y -= 5;
  126.         E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
  127. #endif
  128.         e_bomb_xc = E_BOMB_ENT.x + 0x0C;
  129.         e_bomb_yc = E_BOMB_ENT.y + 0x000A;
  130.         e_bomb_lethal = TRUE;
  131.         if (e_bomb_hit(E_RICK_NO))
  132.             e_rick_gozombie();
  133.     }
  134.     else
  135.     {
  136.         /*
  137.          * exploding
  138.          */
  139. #ifdef GFXPC
  140.         E_BOMB_ENT.sprite = 0x24 + 4 - (e_bomb_ticker >> 1);
  141. #endif
  142. #ifdef GFXST
  143.         E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
  144. #endif
  145.         /* exploding, hence lethal */
  146.         if (e_bomb_hit(E_RICK_NO))
  147.             e_rick_gozombie();
  148.     }
  149. }
  150.  
  151. /* eof */
  152.  
  153.  
  154.